﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using viBlog.Classes;
using viBlog.Controllers;
using visinia.SmartEngine;
using visinia.SmartEngine.Modules;

public partial class Modules_viBlog_Dynamic_PostsRotator : WebModule
{
    protected void Page_Load(object sender, EventArgs e)
    {
        WebPageController.AddScriptLink(Page, WebRoots.GetModulesRoot + "viBlog/DynamicModules/PostsRotator/Rotator.js");
        WebPageController.AddCssLink(Page, WebRoots.GetModulesRoot + "viBlog/DynamicModules/PostsRotator/Rotator.css");
    }

    protected override void WebModuleRender(HtmlTextWriter output)
    {
        List<Post> list = DataFilterController.GetFilteredData(ModuleId);
        if (list == null)
            return;
        List<string> text = new List<string>();
        List<string> links = new List<string>();
        foreach (Post post in list)
        {
            text.Add(post.Title);
            links.Add(post.Url);
        }        
        string data = WebHelpers.GenerateBulletedListHyperLinks(text.ToArray(), links.ToArray());
        output.Write(data);
    }
}
